from threading import Lock,get_ident

class QRCodeCollection:

    instance = None
    lock = Lock()

    def __init__(self):
        self.__QRCode = {}
        self.data = {}
    @classmethod
    def get_instance(cls):
        cls.lock.acquire()
        if not cls.instance:
            cls.instance = cls()
        cls.lock.release()
        return cls.instance

    def set_QrCode(self,QRCode):
        print(get_ident())
        self.__QRCode[get_ident()] = QRCode

    def getQRCode(self,ident):

        return self.__QRCode.get(ident)
    def set_data(self,k,v):

        self.data[get_ident()] = {}
        self.data[get_ident()][k] = v


    def get_data(self,ident,k):
         data = self.data.get(ident)

         if not data:
             return None
         else:
             return data.get(k)
